﻿#include "TubeFocus.h"

TubeFocus::TubeFocus() : fcsptr(std::make_shared<Focus>())
{

}

TubeFocus::~TubeFocus()
{

}

int TubeFocus::preprocess(cv::Mat& mat, Attribute& attr) {
#ifdef DEBUG
    std::cout << "TubeFucus preprocess." << std::endl;
#endif // DEBUG

    if (0 == fcsptr->preprocess(mat, attr)) {
        if (attr.type == Shapetype::ShapeNone) {
            return -2;
        }
        switch (attr.type) {
        case Circle:
            return preprocessCircle(mat, attr);
        case Rect:
            return preprocessRect(mat, attr);
        default:
            break;
        }
    }

	return 0;
}

int TubeFocus::findMaxOutline(cv::Mat& mat) {
    return fcsptr->findMaxOutline(mat);
}

int TubeFocus::findMaxOutline(cv::Mat& mat, Attribute& attr) {
    return fcsptr->findMaxOutline(mat, attr);
}

int TubeFocus::draw(cv::Mat& mat, Attribute& attr) {
	return fcsptr->draw(mat, attr);
}

cv::Point2f TubeFocus::getMaxOutlineCenter(Attribute& attr) const {
	return fcsptr->getMaxOutlineCenter(attr);
}

int TubeFocus::preprocessCircle(cv::Mat& mat, Attribute& attr)
{
    if (attr.color == Matcolor::ColorNone) {
        return -3;
    }

    // ...

    return 0;
}

int TubeFocus::preprocessRect(cv::Mat& mat, Attribute& attr)
{
    if (attr.color == Matcolor::ColorNone) {
        return -3;
    }
    
    //....

    return 0;
}

